
use "data/working/working_platform.dta", clear
sort household_id currency_id
*cf _all using "data/working/working_sharepost_Jiarui.dta"

*------------------------------------------------------------------------------*
* Estimation Main
*------------------------------------------------------------------------------*


// w/ iv w/o expectation : Change initial value + beta & momentum
// w/ iv w/o expectation : Change initial value + beta & momentum
gmm (dep_weighted * exp(-{xb: logME beta momentum4  pow incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ), ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor ) ///	
		from(logME .2  pow .5  _cons 0) conv_maxiter(100)	 
est save "output/estimates/table5_col1.ster", replace				
		

// w/ iv w/o expectation : Change initial value + beta & momentum + only short-term
gmm (dep_weighted * exp(-{xb: logME beta momentum4  pow short_increase incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ), ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow short_increase incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor ) ///	
		from(logME .3  pow .5  _cons 0) conv_maxiter(100)	 
est save "output/estimates/table5_col2.ster", replace				 
	 
		
// w/ iv w/ expectation	+ beta + momentum  without currency_potential
gmm (dep_weighted * exp(-{xb: logME beta momentum4 pow short_increase long_decrease ///
		 incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ), ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow short_increase long_decrease ///
	    incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor)  ///	
		from(logME .3 pow 0.6  _cons 0) conv_maxiter(100)	 
est save "output/estimates/table5_col3.ster", replace				 
		 		 	 

// w/ iv w/ expectation	+ beta + momentum 
gmm (dep_weighted * exp(-{xb: logME beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ), ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor) ///	
		from(log_libor 0.6  _cons 0) conv_maxiter(100)	 
est save "output/estimates/table5_col4.ster", replace				  
		 		 	 
				
gmm (dep_weighted * exp(-{xb: logME beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ), ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor) ///	
		conv_maxiter(100)	 
est save "output/estimates/table5_col4_check.ster", replace				  
		 
			
*------------------------------------------------------------------------------*
* Estimation Heterogeneity
*------------------------------------------------------------------------------*


*----------- Income
// w/ iv w/ expectation	+ beta + momentum 
gmm (dep_weighted * exp(-{xb: logME beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ) if incomenewdummy == 0, ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor) ///	
		conv_maxiter(200)	
est save "output/estimates/table6_col1.ster", replace	


// w/ iv w/ expectation	+ beta + momentum 
gmm (dep_weighted * exp(-{xb: logME beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ) if incomenewdummy == 1, ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor) ///	
		conv_maxiter(200)	
est save "output/estimates/table6_col2.ster", replace	


*----------- Age
// w/ iv w/ expectation	+ beta + momentum 
gmm (dep_weighted * exp(-{xb: logME beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ) if agenewdummy == 0, ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor) ///	
		conv_maxiter(200)	
est save "output/estimates/table6_col3.ster", replace	


// w/ iv w/ expectation	+ beta + momentum 
gmm (dep_weighted * exp(-{xb: logME beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ) if agenewdummy == 1, ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor) ///	
	    conv_maxiter(200)	
est save "output/estimates/table6_col4.ster", replace	



*----------- Wave
// w/ iv w/ expectation	+ beta + momentum 
gmm (dep_weighted * exp(-{xb: logME beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ) if wave == 1, ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor) ///	
	    conv_maxiter(200)	
est save "output/estimates/table6_col5.ster", replace	


// w/ iv w/ expectation	+ beta + momentum 
gmm (dep_weighted * exp(-{xb: logME beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor _cons}) -1 ) if wave == 2, ///
		vce(cl household_id) tech(bfgs) ///  gn, nr, dfp, bfgs winitial(identity) 
		instruments( logsupply beta momentum4 pow short_increase long_decrease ///
		currencies_potential incomenewdummy agenewdummy countrynewdummy type_objective log_sp500 log_libor) ///	
	    conv_maxiter(200)	
est save "output/estimates/table6_col6.ster", replace	
					 